package com.zksk.mbg.admin.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.zksk.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * <p>
 * 机构（银行、担保、保险）表
 * </p>
 *
 * @author Zksk Acmen
 * @since 2022-12-08
 */
@Data
@Accessors(chain = true)
@TableName("platform_org")
@ApiModel(value = "Org对象", description = "机构（银行、担保、保险）表")
public class Org extends BaseEntity {

    @ApiModelProperty("机构id，主键非空")
    @TableId(value = "org_id", type = IdType.ASSIGN_ID)
    @NotNull(message = "机构ID不能为空!",groups = Update.class)
    private Long orgId;

    @ApiModelProperty("机构编码BX0100 YH0100")
    @TableField("org_code")
    @NotNull(message = "机构编码不能为空!", groups = Update.class)
    @Min(value = 6,message = "机构编码不正确")
    @Max(value = 10,message = "机构编码不正确")
    private String orgCode;

    @ApiModelProperty("机构名称")
    @TableField("org_name")
    @NotNull(message = "机构名称不能为空!", groups = {Insert.class, Update.class})
    private String orgName;

    @ApiModelProperty("机构类型 (0:银行 1：保险 2：担保 3 第三方 4 经纪公司)")
    @TableField("org_type")
    @NotNull(message = "机构类型不能为空!", groups = {Insert.class, Update.class})
    private String orgType;

    @ApiModelProperty("关联担保机构id（银行类型机构生效）")
    @TableField("ref_org_ids")
    private String refOrgIds;

    @ApiModelProperty("关联担保机构名称（银行类型机构生效）")
    @TableField("ref_org_names")
    private String refOrgNames;

    @ApiModelProperty("经济公司（保险类型机构 ）id")
    @TableField("economic_company_id")
    private String economicCompanyId;

    @ApiModelProperty("经济公司/第三方公司url")
    @TableField("company_url")
    private String companyUrl;

    @ApiModelProperty("地区id")
    @TableField("region_id")
    private Long regionId;

    @ApiModelProperty("地区名称")
    @TableField("region_name")
    private String regionName;

    @ApiModelProperty("地址详情")
    @TableField("address_detail")
    private String addressDetail;

    @ApiModelProperty("机构联系人")
    @TableField("contact")
    @NotBlank(message = "任务名称不能为空", groups = {Insert.class, Update.class})
    @Size(min = 2, max = 10, message = "联系人名称字数不能大于10")
    private String contact;

    @ApiModelProperty("机构联系人电话")
    @TableField("contact_tell")
//    @PrivacyEncrypt(type = PrivacyTypeEnum.PHONE) // 隐藏手机号
    @NotNull(message = "机构联系人电话不能为空!",groups = {Insert.class, Update.class})
    @Pattern(regexp = "/^1(3\\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$/", message = "手机号码格式错误", groups = {Insert.class, Update.class})
    private String contactTell;

    @ApiModelProperty("发票类型：1：电子普票   2：专票   3：纸质专票")
    @TableField("invoice_ways")
    private String invoiceWays;

    @ApiModelProperty("预留字段1")
    @TableField("reserved1")
    private String reserved1;

    @ApiModelProperty("预留字段2")
    @TableField("reserved2")
    private String reserved2;

    @TableField(value = "del_flag", fill = FieldFill.INSERT)
    @TableLogic
    private Integer delFlag;


    public static final String ORG_ID = "org_id";

    public static final String ORG_CODE = "org_code";

    public static final String ORG_NAME = "org_name";

    public static final String ORG_TYPE = "org_type";

    public static final String REF_ORG_ID = "ref_org_id";

    public static final String REF_ORG_NAME = "ref_org_name";

    public static final String ECONOMIC_COMPANY_ID = "economic_company_id";

    public static final String REGION_ID = "region_id";

    public static final String REGION_NAME = "region_name";

    public static final String ADDRESS_DETAIL = "address_detail";

    public static final String CONTACT = "contact";

    public static final String CONTACT_TELL = "contact_tell";

    public static final String INVOICE_WAYS = "invoice_ways";

    public static final String RESERVED1 = "reserved1";

    public static final String RESERVED2 = "reserved2";

    public static final String DEL_FLAG = "del_flag";

    @Override
    public Serializable pkVal() {
        return this.orgId;
    }

}
